﻿using Infrastructure.Web;
using MyApplication;
using MyWeb.App_Start;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyWeb.Controllers
{
    public class BaseController : Controller
    {
        public AdminUserApp adminUserApp { get; set; }
        public DepartApp departApp { get; set; }
        public DepartMobileRLApp departMobileRLApp { get; set; }
        public MobileApp mobileApp { get; set; }
        public UserInfoApp userInfoApp { get; set; }
        public VisitorApp visitorApp { get; set; }
        public SystemConfigApp SystemConfigApp { get; set; }
        public AccessRecordApp AccessRecordApp { get; set; }
        public MeetApp MeetApp { get; set; }
        public HolidayApp HolidayApp { get; set; }
        public CarRecordApp CarRecordApp { get; set; }
        public SynsRLApp SynsRlApp { get; set; }
        public SyncErrorApp SyncErrorApp { get; set; }
        public BaseController()
        {

        }
        protected JsonResult Try(Action action)
        {
            var result = new AjaxResult();
            try
            {
                action();
            }
            catch (Exception ex)
            {
                result.state=(int)ResultType.error;
                result.message = ex.Message;
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        protected JsonResult Try<T>(Action action, AjaxResult<T> result)
        {
            try
            {
                action();
            }
            catch (Exception ex)
            {
                result.state = (int)ResultType.error;
                result.message = ex.Message;
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }

    }
}